// createRouter：方法 用来创建router实例对象 new Router()
// createWebHashHistory: 方法 用来创建hash模式的路由实例(#)
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Category from '@/views/Category'
import Home from '@/views/Home'
import Good from '@/views/Good'
import Cart from '@/views/Cart'
import Settle from '@/views/Settle'
import Pay from '@/views/Pay'
// 配置path和component配置项
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '', // path置空 将作为默认的二级路由显示
        component: Home
      },
      {
        path: 'category/:id',
        component: Category
      },
      {
        path: 'good/:id',
        component: Good
      },
      {
        path: 'cart',
        component: Cart
      },
      {
        path: 'settle',
        component: Settle
      },
      {
        path: 'pay/:id',
        component: Pay
      }
    ]
  },
  {
    path: '/login',
    component: Login
  }
]

// 创建路由实例对象 导出给main.js使用
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
